const { marked } = require("marked"); //版本4.3.0
const hljs = require("highlight.js");

module.exports = function (content) {
  //语法高亮
  marked.setOptions({
    highlight: function (code, lang) {
      return hljs.highlight(lang, code).value;
    },
  });

  //将md语法转化为html元素结构
  const htmlCode = marked(content);

  console.log(htmlCode);

  //返回的结果必须是模块化内容
  const innerContent = "`" + htmlCode + "`";
  const moduleContent = `var code=${innerContent};export default code`;

  return moduleContent;
};
